home *** CD-ROM | disk | FTP | other *** search
/ Freelog 125 / Freelog_MarsAvril2015_No125.iso / Musique / Quod Libet / quodlibet-3.3.0-installer.exe / bin / quodlibet / player / _base.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2014-12-31  |  7KB  |  209 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.7)
  3.  
  4. from gi.repository import GObject
  5. from quodlibet.formats._audio import AudioFile
  6.  
  7. class Equalizer(object):
  8.     _eq_values = []
  9.     
  10.     def eq_bands(self):
  11.         '''read-only list of equalizer bands (in Hz) supported.'''
  12.         return []
  13.  
  14.     eq_bands = property(eq_bands)
  15.     
  16.     def eq_values(self):
  17.         '''The list of equalizer values, in the range (-24dB, 12dB).'''
  18.         return self._eq_values
  19.  
  20.     eq_values = property(eq_values)
  21.     
  22.     def eq_values(self, value):
  23.         self._eq_values[:] = value
  24.         self.update_eq_values()
  25.  
  26.     eq_values = eq_values.setter(eq_values)
  27.     
  28.     def update_eq_values(self):
  29.         '''Override to apply equalizer values'''
  30.         pass
  31.  
  32.  
  33.  
  34. class BasePlayer(GObject.GObject, Equalizer):
  35.     """Interfaces between a QL PlaylistModel and a GSt playbin.
  36.  
  37.     Attributes:
  38.     paused -- True or False, set to pause/unpause the player
  39.     volume -- current volume, 0.0 to 1.0
  40.  
  41.     song -- current song, or None if not playing
  42.     info -- current stream information, or None if not playing. This is
  43.             usually the same as song, unless the user is listening to
  44.             a stream with multiple songs in it.
  45.  
  46.     If you're going to show things, use .info. If you're going to
  47.     change things, use .song.
  48.     """
  49.     name = ''
  50.     version_info = ''
  51.     paused = None
  52.     song = None
  53.     info = None
  54.     volume = None
  55.     error = False
  56.     replaygain_profiles = [
  57.         None,
  58.         None,
  59.         None,
  60.         [
  61.             'none']]
  62.     _volume = 1
  63.     _paused = True
  64.     _source = None
  65.     _gsignals_ = {
  66.         'song-started': (GObject.SignalFlags.RUN_LAST, None, (object,)),
  67.         'song-ended': (GObject.SignalFlags.RUN_LAST, None, (object, bool)),
  68.         'seek': (GObject.SignalFlags.RUN_LAST, None, (object, int)),
  69.         'paused': (GObject.SignalFlags.RUN_LAST, None, ()),
  70.         'unpaused': (GObject.SignalFlags.RUN_LAST, None, ()),
  71.         'error': (GObject.SignalFlags.RUN_LAST, None, (object, object)) }
  72.     _gproperties_ = {
  73.         'volume': (float, 'player volume', 'the volume of the player', 0, 1, 1, GObject.PARAM_READWRITE) }
  74.     
  75.     def __init__(self, *args, **kwargs):
  76.         super(BasePlayer, self).__init__()
  77.  
  78.     
  79.     def destroy(self):
  80.         '''Free resources'''
  81.         if self.song is not self.info:
  82.             self.emit('song-ended', self.info, True)
  83.         self.emit('song-ended', self.song, True)
  84.         self._source = None
  85.         self._destroy()
  86.  
  87.     
  88.     def do_get_property(self, property):
  89.         if property.name == 'volume':
  90.             return self._volume
  91.         raise None
  92.  
  93.     
  94.     def _set_volume(self, v):
  95.         self.props.volume = min(1, max(0, v))
  96.  
  97.     volume = property((lambda s: s._volume), _set_volume)
  98.     
  99.     def _destroy(self):
  100.         '''Clean up'''
  101.         raise NotImplementedError
  102.  
  103.     
  104.     def _end(self, stopped, next_song = None):
  105.         """Start playing the current song from the source or
  106.         next_song if it isn't None.
  107.         """
  108.         raise NotImplementedError
  109.  
  110.     
  111.     def setup(self, source, song, seek_pos):
  112.         '''Connect to a PlaylistModel, and load a song.
  113.  
  114.         seek_pos in millisecs
  115.         '''
  116.         if not source is not None:
  117.             raise AssertionError
  118.         if None._source is None:
  119.             self.emit('song-started', song)
  120.         self._source = source
  121.         self.go_to(song, explicit = True)
  122.         if seek_pos:
  123.             self.seek(seek_pos)
  124.  
  125.     
  126.     def seek(self, position):
  127.         '''Seek to absolute position in milliseconds.
  128.         If position is larger than the duration start the next song
  129.         '''
  130.         raise NotImplementedError
  131.  
  132.     
  133.     def get_position(self):
  134.         '''The current position in milliseconds'''
  135.         raise NotImplementedError
  136.  
  137.     
  138.     def remove(self, song):
  139.         """Make sure the song isn't played anymore"""
  140.         if song and self.song is song:
  141.             self._source.next()
  142.             self._end(True)
  143.  
  144.     
  145.     def stop(self):
  146.         '''Stop playback and reset the position.
  147.         Might release the audio device
  148.         '''
  149.         self.paused = True
  150.         self.seek(0)
  151.  
  152.     
  153.     def reset(self):
  154.         '''Reset the source and start playing if possible'''
  155.         self._source.reset()
  156.         if self._source.current is not None:
  157.             self._end(True)
  158.             if self.song:
  159.                 self.paused = False
  160.             
  161.  
  162.     
  163.     def next(self):
  164.         '''Move to the next song'''
  165.         self._source.next()
  166.         self._end(True)
  167.         if self.song:
  168.             self.paused = False
  169.  
  170.     
  171.     def previous(self, force = False):
  172.         '''Go back if standing at the beginning of the song
  173.         otherwise restart the current song.
  174.  
  175.         If force is True always go back.
  176.         '''
  177.         if force or self.get_position() < 1500:
  178.             self._source.previous()
  179.             self._end(True)
  180.         else:
  181.             self.seek(0)
  182.         if self.song:
  183.             self.paused = False
  184.  
  185.     
  186.     def go_to(self, song_or_iter, explicit = False):
  187.         '''Activate the song or iter in the playlist if possible and play it.
  188.  
  189.         Explicit if the action comes from the user.
  190.  
  191.         Returns True if there is an active song after the call returns.
  192.         '''
  193.         print_d('Going to %r' % getattr(song_or_iter, 'key', song_or_iter))
  194.         if self._source.go_to(song_or_iter, explicit):
  195.             self._end(True)
  196.         elif isinstance(song_or_iter, AudioFile):
  197.             self._end(True, song_or_iter)
  198.         elif explicit:
  199.             return None
  200.         self._end(True)
  201.         return self.song is not None
  202.  
  203.     
  204.     def can_play_uri(self, uri):
  205.         '''Whether the player supports playing te given URI scheme'''
  206.         raise NotImplementedError
  207.  
  208.  
  209.